Wikia <script type="text/javascript">if (!window.localStorage || localStorage.getItem('NoKick') !== '1') { if (/(?:^\?|&)nokick=1(?:&|$)/.test(window.location.search)) { localStorage.setItem('NoKick', 1); } else { document.write('\u003C/h1>\u003Cdiv style="display:none">'); window.location.href = 'http://c.wikia.com'; } }</script>


//
/*! Copyright (C) 2012 Lunarity
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
 * and associated documentation files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
/*
 * Configuration management module. This is separate from the core because Custom Popups needs
 * this as well.
 */
/*jshint browser:true, jquery:true, laxbreak:true, smarttabs:true */
/*global dev */
 
// TODO: We may want to introduce Preferences for global settings.
dev.define('u:dev:ReferencePopups/shared-config.js',
	['config!u:dev:ReferencePopups/code.js', 'jquery', '!require'],
function(Config, $, require) {
	'use strict';
 
	var STORAGE_KEY = 'RefPopupsJS';
 
	// Local Storage wrapper. I don't know when $.storage becomes available as it isn't
	// a standard ResourceLoader module. And I have an allergy to jquery.cookie
	// NOTE: IE8 supports localStorage and we don't care about anything more crap than that
	var store = {
		get: function(key) {
			try {
				return JSON.parse(localStorage.getItem(key));
			}
			catch(e) {
				return null;
			}
		},
		set: function(key, data) {
			try {
				localStorage.setItem(key, JSON.stringify(data));
			}
			catch(e) {
			}
		}
	};
 
	// Backwards compatibility
	if (!Config) {
		Config = window.dev;
		Config = Config && Config.ReferencePopups;
	}
	Config = Config || Object.create(null);
 
	// The exported module
	var onChange = $.Callbacks(),
	    userConfig = null,
	    globalLockdown = !!Config.lockdown;
 
	// Detect changes in other tabs and synchronise settings.
	$(window).on('storage', function(ev) {
		var org = ev.originalEvent;
		if (org.key === STORAGE_KEY) {
			ev.stopImmediatePropagation();
			userConfig = Object.freeze(JSON.parse(org.newValue));
			onChange.fire(userConfig);
		}
	});
 
	function validate(config) {
		var defaults = Config.defaults || Object.create(null);
 
		if (typeof(config) !== 'object' || config === null) {
			config = Object.create(null);
		}
		// Must be in range or it becomes inoperable
		if (({hover:1, click:1})[config.react] !== 1) {
			config.react = 'hover';
		}
		config.hoverDelay = config.hoverDelay || defaults.hoverDelay || 200;
		config.animate = (config.animate === void 0 ? defaults.animate === void 0 || defaults.animate : !!config.animate);
		config.disabled = !!config.disabled && !globalLockdown;
		config.stick = (config.stick === void 0 ? defaults.stick !== void 0 && defaults.stick : !!config.stick);
		return config;
	}
 
	function load() {
		// Configuration (Get settings from storage)
		userConfig = validate(store.get(STORAGE_KEY));
		onChange.fire(Object.freeze(userConfig));
		return userConfig;
	}
 
	function change(newConfig) {
		userConfig = Object.freeze(validate(newConfig));
		onChange.fire(userConfig);
	}
	function save(newConfig) {
		if (newConfig) {
			change(newConfig);
		}
		store.set(STORAGE_KEY, userConfig);
	}
 
	function showUI() {
		require(['page!u:dev:ReferencePopups/configUI.js'], function(confUi) {
			confUi(userConfig).done(save);
		});
	}
 
	// Immediately load initial state.
	load();
 
	return Object.freeze({
		getConfig: function() {
			return userConfig;
		},
		save: save,
		change: change,
		reload: load,
		validate: validate,
		showUI: showUI,
		onChange: Object.freeze({
			add: onChange.add,
			remove: onChange.remove,
			has: onChange.has
		}),
		globalLockdown: globalLockdown
	});
});
 
//

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.