You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
31 KiB

{"version":3,"sources":["state.js"],"names":["$","window","document","undefined","Math","self","Function","fn","state","parameters","returnedValue","$allModules","this","moduleSelector","selector","time","documentElement","Date","getTime","performance","query","arguments","methodInvoked","queryArguments","slice","call","each","module","settings","isPlainObject","extend","error","metadata","className","namespace","states","text","eventNamespace","moduleNamespace","$module","element","instance","data","initialize","verbose","automatic","add","defaults","context","on","change","reset","toggle","instantiate","destroy","off","removeData","refresh","userStates","type","typeStates","is","active","hasClass","loading","inactive","enabled","filter","disabled","textEnabled","button","input","progress","allow","debug","disallow","allows","enable","removeClass","disable","addClass","setState","removeState","apiRequest","requestCancelled","api","activateTest","deactivateTest","listenTo","update","when","then","activate","deactivate","sync","onChange","hover","onActivate","onDeactivate","not","get","find","html","textFor","flash","duration","callback","previousText","flashDuration","setTimeout","activeText","storedText","inactiveText","currentText","setting","name","value","internal","silent","log","prototype","bind","console","info","apply","message","currentTime","executionTime","previousTime","push","Name","Arguments","Element","Execution Time","clearTimeout","timer","display","title","totalTime","index","group","table","length","groupCollapsed","groupEnd","invoke","passedArguments","maxDepth","found","response","object","split","depth","camelCaseValue","charAt","toUpperCase","method","isFunction","isArray","beforeSend","promise","success","warning","jQuery"],"mappings":";;;;;;;;;CAUC,SAAWA,EAAGC,EAAQC,EAAUC,GAEjC,YAEAF,GAA2B,mBAAVA,IAAyBA,EAAOG,MAAQA,KACrDH,EACgB,mBAARI,OAAuBA,KAAKD,MAAQA,KAC1CC,KACAC,SAAS,iBAGfN,EAAEO,GAAGC,MAAQ,SAASC,GACpB,GAaEC,GAZAC,EAAkBX,EAAEY,MAEpBC,EAAkBF,EAAYG,UAAY,GAG1CC,GADmB,gBAAkBb,GAASc,iBAC5B,GAAIC,OAAOC,WAC7BC,KAEAC,EAAkBC,UAAU,GAC5BC,EAAmC,gBAATF,GAC1BG,KAAqBC,MAAMC,KAAKJ,UAAW,EA4iB7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ThB,EAAOsH,OAAO7H,KAGXqB,IAAatC,GACdsC,EAASwG,OAAO,WAElBtH,EAAOgB,gBAKLjC,IAAkBP,EACtBO,EACAE,MAINZ,EAAEO,GAAGC,MAAMoB,UAGTuF,KAAiB,QAGjBzC,OAAiB,EAGjB9B,SAAiB,EAGjBV,UAAiB,QAGjBf,aAAiB,EAGjB8E,WAAiB,aACjBC,aAAiB,aACjBH,SAAiB,aAGjBT,aAAiB,WAAa,OAAO,GACrCC,eAAiB,WAAa,OAAO,GAGrC1C,WAAiB,EAGjBiD,MAAiB,EAGjBc,cAAiB,IAGjBzC,QACE/B,KAAS,sBACT0B,OAAS,aAGXd,SAAa,EAGbjB,OACEgI,WAAa,sDACbH,OAAa,yCAIf5H,UACEgI,QAAa,UACbjD,WAAa,eAIf9E,WACE6B,OAAW,SACXM,SAAW,WACXrC,MAAW,QACXiC,QAAW,UACXiG,QAAW,UACXC,QAAW,WAGbpJ,UAEEsB,MAAM,GAGRW,UACEwB,OACEH,UAAW,EACXJ,SAAW,EACXF,QAAW,GAEbQ,QACEF,UAAW,EACXJ,SAAW,EACXF,QAAW,GAEbU,UACEV,QAAW,EACXmG,SAAW,EACXC,SAAW,EACXnI,OAAW,IAIfI,QACE2B,QAAW,EACXM,UAAW,EACXrC,OAAW,EACXiC,SAAW,EACXiG,SAAW,EACXC,SAAW,GAGb9H,MACEgC,UAAa,EACboC,OAAa,EACbR,OAAa,EACblC,QAAa,EACbG,UAAa,EACb2B,UAAa,EACbC,YAAa,KAObsE,OAAQlK,OAAQC","file":"state.min.js","sourcesContent":["/*!\n * # Semantic UI 2.2.6 - State\n * http://github.com/semantic-org/semantic-ui/\n *\n *\n * Released under the MIT license\n * http://opensource.org/licenses/MIT\n *\n */\n\n;(function ($, window, document, undefined) {\n\n\"use strict\";\n\nwindow = (typeof window != 'undefined' && window.Math == Math)\n ? window\n : (typeof self != 'undefined' && self.Math == Math)\n ? self\n : Function('return this')()\n;\n\n$.fn.state = function(parameters) {\n var\n $allModules = $(this),\n\n moduleSelector = $allModules.selector || '',\n\n hasTouch = ('ontouchstart' in document.documentElement),\n time = new Date().getTime(),\n performance = [],\n\n query = arguments[0],\n methodInvoked = (typeof query == 'string'),\n queryArguments = [].slice.call(arguments, 1),\n\n returnedValue\n ;\n $allModules\n .each(function() {\n var\n settings = ( $.isPlainObject(parameters) )\n ? $.extend(true, {}, $.fn.state.settings, parameters)\n : $.extend({}, $.fn.state.settings),\n\n error = settings.error,\n metadata = settings.metadata,\n className = settings.className,\n namespace = settings.namespace,\n states = settings.states,\n text = settings.text,\n\n eventNamespace = '.' + namespace,\n moduleNamespace = namespace + '-module',\n\n $module = $(this),\n\n element = this,\n instance = $module.data(moduleNamespace),\n\n module\n ;\n module = {\n\n initialize: function() {\n module.verbose('Initializing module');\n\n // allow module to guess desired state based on element\n if(settings.automatic) {\n module.add.defaults();\n }\n\n // bind events with delegated events\n if(settings.context && moduleSelector !== '') {\n $(settings.context)\n .on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text)\n .on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text)\n .on(moduleSelector, 'click' + eventNamespace, module.toggle.state)\n ;\n }\n else {\n $module\n .on('mouseenter' + eventNamespace, module.change.text)\n .on('mouseleave' + eventNamespace, module.reset.text)\n .on('click' + eventNamespace, module.toggle.state)\n ;\n }\n module.instantiate();\n },\n\n instantiate: function() {\n module.verbose('Storing instance of module', module);\n instance = module;\n $module\n .data(moduleNamespace, module)\n ;\n },\n\n destroy: function() {\n module.verbose('Destroying previous module', instance);\n $module\n .off(eventNamespace)\n .removeData(moduleNamespace)\n ;\n },\n\n refresh: function() {\n module.verbose('Refreshing selector cache');\n $module = $(element);\n },\n\n add: {\n defaults: function() {\n var\n userStates = parameters && $.isPlainObject(parameters.states)\n ? parameters.states\n : {}\n ;\n $.each(settings.defaults, function(type, typeStates) {\n if( module.is[type] !== undefined && module.is[type]() ) {\n module.verbose('Adding default states', type, element);\n $.extend(settings.states, typeStates, userStates);\n }\n });\n }\n },\n\n is: {\n\n active: function() {\n return $module.hasClass(className.active);\n },\n loading: function() {\n return $module.hasClass(className.loading);\n },\n inactive: function() {\n return !( $module.hasClass(className.active) );\n },\n state: function(state) {\n if(className[state] === undefined) {\n return false;\n }\n return $module.hasClass( className[state] );\n },\n\n enabled: function() {\n return !( $module.is(settings.filter.active) );\n },\n disabled: function() {\n return ( $module.is(settings.filter.active) );\n },\n textEnabled: function() {\n return !( $module.is(settings.filter.text) );\n },\n\n // definitions for automatic type detection\n button: function() {\n return $module.is('.button:not(a, .submit)');\n },\n input: function() {\n return $module.is('input');\n },\n progress: function() {\n return $module.is('.ui.progress');\n }\n },\n\n allow: function(state) {\n module.debug('Now allowing state', state);\n states[state] = true;\n },\n disallow: function(state) {\n module.debug('No longer allowing', state);\n states[state] = false;\n },\n\n allows: function(state) {\n return states[state] || false;\n },\n\n enable: function() {\n $module.removeClass(className.disabled);\n },\n\n disable: function() {\n $module.addClass(className.disabled);\n },\n\n setState: function(state) {\n if(module.allows(state)) {\n $module.addClass( className[state] );\n }\n },\n\n removeState: function(state) {\n if(module.allows(state)) {\n $module.removeClass( className[state] );\n }\n },\n\n toggle: {\n state: function() {\n var\n apiRequest,\n requestCancelled\n ;\n if( module.allows('active') && module.is.enabled() ) {\n module.refresh();\n if($.fn.api !== undefined) {\n apiRequest = $module.api('get request');\n requestCancelled = $module.api('was cancelled');\n if( requestCancelled ) {\n module.debug('API Request cancelled by beforesend');\n settings.activateTest = function(){ return false; };\n settings.deactivateTest = function(){ return false; };\n }\n else if(apiRequest) {\n module.listenTo(apiRequest);\n return;\n }\n }\n module.change.state();\n }\n }\n },\n\n listenTo: function(apiRequest) {\n module.debug('API request detected, waiting for state signal', apiRequest);\n if(apiRequest) {\n if(text.loading) {\n module.update.text(text.loading);\n }\n $.when(apiRequest)\n .then(function() {\n if(apiRequest.state() == 'resolved') {\n module.debug('API request succeeded');\n settings.activateTest = function(){ return true; };\n settings.deactivateTest = function(){ return true; };\n }\n else {\n module.debug('API request failed');\n settings.activateTest = function(){ return false; };\n settings.deactivateTest = function(){ return false; };\n }\n module.change.state();\n })\n ;\n }\n },\n\n // checks whether active/inactive state can be given\n change: {\n\n state: function() {\n module.debug('Determining state change direction');\n // inactive to active change\n if( module.is.inactive() ) {\n module.activate();\n }\n else {\n module.deactivate();\n }\n if(settings.sync) {\n module.sync();\n }\n settings.onChange.call(element);\n },\n\n text: function() {\n if( module.is.textEnabled() ) {\n if(module.is.disabled() ) {\n module.verbose('Changing text to disabled text', text.hover);\n module.update.text(text.disabled);\n }\n else if( module.is.active() ) {\n if(text.hover) {\n module.verbose('Changing text to hover text', text.hover);\n module.update.text(text.hover);\n }\n else if(text.deactivate) {\n module.verbose('Changing text to deactivating text', text.deactivate);\n module.update.text(text.deactivate);\n }\n }\n else {\n if(text.hover) {\n module.verbose('Changing text to hover text', text.hover);\n module.update.text(text.hover);\n }\n else if(text.activate){\n module.verbose('Changing text to activating text', text.activate);\n module.update.text(text.activate);\n }\n }\n }\n }\n\n },\n\n activate: function() {\n if( settings.activateTest.call(element) ) {\n module.debug('Setting state to active');\n $module\n .addClass(className.active)\n ;\n module.update.text(text.active);\n settings.onActivate.call(element);\n }\n },\n\n deactivate: function() {\n if( settings.deactivateTest.call(element) ) {\n module.debug('Setting state to inactive');\n $module\n .removeClass(className.active)\n ;\n module.update.text(text.inactive);\n settings.onDeactivate.call(element);\n }\n },\n\n sync: function() {\n module.verbose('Syncing other buttons to current state');\n if( module.is.active() ) {\n $allModules\n .not($module)\n .state('activate');\n }\n else {\n $allModules\n .not($module)\n .state('deactivate')\n ;\n }\n },\n\n get: {\n text: function() {\n return (settings.selector.text)\n ? $module.find(settings.selector.text).text()\n : $module.html()\n ;\n },\n textFor: function(state) {\n return text[state] || false;\n }\n },\n\n flash: {\n text: function(text, duration, callback) {\n var\n previousText = module.get.text()\n ;\n module.debug('Flashing text message', text, duration);\n text = text || settings.text.flash;\n duration = duration || settings.flashDuration;\n callback = callback || function() {};\n module.update.text(text);\n setTimeout(function(){\n module.update.text(previousText);\n callback.call(element);\n }, duration);\n }\n },\n\n reset: {\n // on mouseout sets text to previous value\n text: function() {\n var\n activeText = text.active || $module.data(metadata.storedText),\n inactiveText = text.inactive || $module.data(metadata.storedText)\n ;\n if( module.is.textEnabled() ) {\n if( module.is.active() && activeText) {\n module.verbose('Resetting active text', activeText);\n module.update.text(activeText);\n }\n else if(inactiveText) {\n module.verbose('Resetting inactive text', activeText);\n module.update.text(inactiveText);\n }\n }\n }\n },\n\n update: {\n text: function(text) {\n var\n currentText = module.get.text()\n ;\n if(text && text !== currentText) {\n module.debug('Updating text', text);\n if(settings.selector.text) {\n $module\n .data(metadata.storedText, text)\n .find(settings.selector.text)\n .text(text)\n ;\n }\n else {\n $module\n .data(metadata.storedText, text)\n .html(text)\n ;\n }\n }\n else {\n module.debug('Text is already set, ignoring update', text);\n }\n }\n },\n\n setting: function(name, value) {\n module.debug('Changing setting', name, value);\n if( $.isPlainObject(name) ) {\n $.extend(true, settings, name);\n }\n else if(value !== undefined) {\n if($.isPlainObject(settings[name])) {\n $.extend(true, settings[name], value);\n }\n else {\n settings[name] = value;\n }\n }\n else {\n return settings[name];\n }\n },\n internal: function(name, value) {\n if( $.isPlainObject(name) ) {\n $.extend(true, module, name);\n }\n else if(value !== undefined) {\n module[name] = value;\n }\n else {\n return module[name];\n }\n },\n debug: function() {\n if(!settings.silent && settings.debug) {\n if(settings.performance) {\n module.performance.log(arguments);\n }\n else {\n module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');\n module.debug.apply(console, arguments);\n }\n }\n },\n verbose: function() {\n if(!settings.silent && settings.verbose && settings.debug) {\n if(settings.performance) {\n module.performance.log(arguments);\n }\n else {\n module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');\n module.verbose.apply(console, arguments);\n }\n }\n },\n error: function() {\n if(!settings.silent) {\n module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');\n module.error.apply(console, arguments);\n }\n },\n performance: {\n log: function(message) {\n var\n currentTime,\n executionTime,\n previousTime\n ;\n if(settings.performance) {\n currentTime = new Date().getTime();\n previousTime = time || currentTime;\n executionTime = currentTime - previousTime;\n time = currentTime;\n performance.push({\n 'Name' : message[0],\n 'Arguments' : [].slice.call(message, 1) || '',\n 'Element' : element,\n 'Execution Time' : executionTime\n });\n }\n clearTimeout(module.performance.timer);\n module.performance.timer = setTimeout(module.performance.display, 500);\n },\n display: function() {\n var\n title = settings.name + ':',\n totalTime = 0\n ;\n time = false;\n clearTimeout(module.performance.timer);\n $.each(performance, function(index, data) {\n totalTime += data['Execution Time'];\n });\n title += ' ' + totalTime + 'ms';\n if(moduleSelector) {\n title += ' \\'' + moduleSelector + '\\'';\n }\n if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {\n console.groupCollapsed(title);\n if(console.table) {\n console.table(performance);\n }\n else {\n $.each(performance, function(index, data) {\n console.log(data['Name'] + ': ' + data['Execution Time']+'ms');\n });\n }\n console.groupEnd();\n }\n performance = [];\n }\n },\n invoke: function(query, passedArguments, context) {\n var\n object = instance,\n maxDepth,\n found,\n response\n ;\n passedArguments = passedArguments || queryArguments;\n context = element || context;\n if(typeof query == 'string' && object !== undefined) {\n query = query.split(/[\\. ]/);\n maxDepth = query.length - 1;\n $.each(query, function(depth, value) {\n var camelCaseValue = (depth != maxDepth)\n ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)\n : query\n ;\n if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {\n object = object[camelCaseValue];\n }\n else if( object[camelCaseValue] !== undefined ) {\n found = object[camelCaseValue];\n return false;\n }\n else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {\n object = object[value];\n }\n else if( object[value] !== undefined ) {\n found = object[value];\n return false;\n }\n else {\n module.error(error.method, query);\n return false;\n }\n });\n }\n if ( $.isFunction( found ) ) {\n response = found.apply(context, passedArguments);\n }\n else if(found !== undefined) {\n response = found;\n }\n if($.isArray(returnedValue)) {\n returnedValue.push(response);\n }\n else if(returnedValue !== undefined) {\n returnedValue = [returnedValue, response];\n }\n else if(response !== undefined) {\n returnedValue = response;\n }\n return found;\n }\n };\n\n if(methodInvoked) {\n if(instance === undefined) {\n module.initialize();\n }\n module.invoke(query);\n }\n else {\n if(instance !== undefined) {\n instance.invoke('destroy');\n }\n module.initialize();\n }\n })\n ;\n\n return (returnedValue !== undefined)\n ? returnedValue\n : this\n ;\n};\n\n$.fn.state.settings = {\n\n // module info\n name : 'State',\n\n // debug output\n debug : false,\n\n // verbose debug output\n verbose : false,\n\n // namespace for events\n namespace : 'state',\n\n // debug data includes performance\n performance : true,\n\n // callback occurs on state change\n onActivate : function() {},\n onDeactivate : function() {},\n onChange : function() {},\n\n // state test functions\n activateTest : function() { return true; },\n deactivateTest : function() { return true; },\n\n // whether to automatically map default states\n automatic : true,\n\n // activate / deactivate changes all elements instantiated at same time\n sync : false,\n\n // default flash text duration, used for temporarily changing text of an element\n flashDuration : 1000,\n\n // selector filter\n filter : {\n text : '.loading, .disabled',\n active : '.disabled'\n },\n\n context : false,\n\n // error\n error: {\n beforeSend : 'The before send function has cancelled state change',\n method : 'The method you called is not defined.'\n },\n\n // metadata\n metadata: {\n promise : 'promise',\n storedText : 'stored-text'\n },\n\n // change class on state\n className: {\n active : 'active',\n disabled : 'disabled',\n error : 'error',\n loading : 'loading',\n success : 'success',\n warning : 'warning'\n },\n\n selector: {\n // selector for text node\n text: false\n },\n\n defaults : {\n input: {\n disabled : true,\n loading : true,\n active : true\n },\n button: {\n disabled : true,\n loading : true,\n active : true,\n },\n progress: {\n active : true,\n success : true,\n warning : true,\n error : true\n }\n },\n\n states : {\n active : true,\n disabled : true,\n error : true,\n loading : true,\n success : true,\n warning : true\n },\n\n text : {\n disabled : false,\n flash : false,\n hover : false,\n active : false,\n inactive : false,\n activate : false,\n deactivate : false\n }\n\n};\n\n\n\n})( jQuery, window, document );\n"]}