Browse Source

Added user profile and edit/delete.

tags/2.0.3
Teknikode 5 years ago
parent
commit
994be5a459

+ 11
- 16
Teknik/App_Start/BundleConfig.cs View File

@@ -10,32 +10,27 @@ namespace Teknik
{
BundleTable.EnableOptimizations = true;

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new StyleBundle("~/Content/Common").Include(
"~/Content/bootstrap.css",
"~/Content/font-awesome.css",
"~/Content/teknik.css"));

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/common").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery.validate*",
"~/Scripts/common.js",
"~/Scripts/bootstrap.js",
"~/Scripts/bootstrap-select.js",
"~/Scripts/respond.js"));

// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));

bundles.Add(new ScriptBundle("~/bundles/markdown").Include(
"~/Scripts/PageDown/Markdown.Converter.js",
"~/Scripts/PageDown/Markdown.Sanitizer.js"));

bundles.Add(new ScriptBundle("~/bundles/common").Include(
"~/Scripts/common.js"));

bundles.Add(new StyleBundle("~/Content/Common").Include(
"~/Content/bootstrap.css",
"~/Content/font-awesome.css",
"~/Content/teknik.css"));
}
}
}

+ 5
- 0
Teknik/Areas/Home/HomeAreaRegistration.cs View File

@@ -48,6 +48,11 @@ namespace Teknik.Areas.Home
// Register Style Bundles
BundleTable.Bundles.Add(new StyleBundle("~/Content/home").Include(
"~/Areas/Home/Content/Home.css"));

// Register Script Bundles
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/home").Include(
"~/Scripts/PageDown/Markdown.Converter.js",
"~/Scripts/PageDown/Markdown.Sanitizer.js"));
}
}
}

+ 1
- 0
Teknik/Areas/Home/Views/Home/Index.cshtml View File

@@ -3,6 +3,7 @@
@using Teknik.Areas.Blog.Models

@Styles.Render("~/Content/home")
@Scripts.Render("~/bundles/home")

<div class="container">
<div class="row">

+ 95
- 3
Teknik/Areas/Profile/Controllers/ProfileController.cs View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
@@ -22,10 +23,41 @@ namespace Teknik.Areas.Profile.Controllers
[AllowAnonymous]
public ActionResult Index(string username)
{
ViewBag.Title = Config.Title + " - Profile";
ViewBag.Message = "View Your Profile";
if (string.IsNullOrEmpty(username))
{
username = User.Identity.Name;
}

ProfileViewModel model = null;
ViewBag.Title = "User Does Not Exist - " + Config.Title;
ViewBag.Message = "The User does not exist";

User user = db.Users.Where(u => u.Username == username).First();

return View(new ProfileViewModel());
if (user != null)
{
ViewBag.Title = username + "'s Profile - " + Config.Title;
ViewBag.Message = "Viewing " + username + "'s Profile";

model = new ProfileViewModel();
model.UserID = user.UserId;
model.Username = user.Username;
model.Email = string.Format("{0}@{1}", user.Username, Config.Host);
model.JoinDate = user.JoinDate;
model.LastSeen = user.LastSeen;
model.About = user.About;
model.Website = user.Website;
model.Quote = user.Quote;

// fill in Blog details
Blog.Models.Blog blog = db.Blogs.Where(b => b.UserId == user.UserId && b.BlogId != Constants.SERVERBLOGID).First();
if (blog != null)
{
model.BlogTitle = blog.Title;
model.BlogDescription = blog.Description;
}
}
return View(model);
}

[HttpGet]
@@ -120,5 +152,65 @@ namespace Teknik.Areas.Profile.Controllers
return Json(new { error = "You must include all fields." });
}

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(string curPass, string newPass, string newPassConfirm, string website, string quote, string about, string blogTitle, string blogDesc)
{
if (ModelState.IsValid)
{
User user = db.Users.Where(u => u.Username == User.Identity.Name).First();
if (user != null)
{
Blog.Models.Blog blog = db.Blogs.Where(b => b.UserId == user.UserId && b.BlogId != Constants.SERVERBLOGID).First();
if (blog != null)
{
// Changing Password?
if (!string.IsNullOrEmpty(curPass) && (!string.IsNullOrEmpty(newPass) || !string.IsNullOrEmpty(newPassConfirm)))
{
// Old Password Valid?
if (SHA384.Hash(User.Identity.Name, curPass) != user.HashedPassword)
{
return Json(new { error = "Invalid Original Password." });
}
// The New Password Match?
if (newPass != newPassConfirm)
{
return Json(new { error = "New Password Must Match." });
}
user.HashedPassword = SHA384.Hash(User.Identity.Name, newPass);
}
user.Website = website;
user.Quote = quote;
user.About = about;

blog.Title = blogTitle;
blog.Description = blogDesc;

db.Entry(blog).State = EntityState.Modified;
db.Entry(user).State = EntityState.Modified;
db.SaveChanges();
return Json(new { result = true });
}
}
}
return Json(new { error = "Unable to save profile." });
}

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int postID)
{
if (ModelState.IsValid)
{
User user = db.Users.Where(u => u.Username == User.Identity.Name).First();
if (user != null)
{
db.Users.Remove(user);
db.SaveChanges();
return Redirect(Url.SubRouteUrl("www", "Home.Index"));
}
}
return Json(new { error = "Unable to delete user." });
}
}
}

+ 9
- 0
Teknik/Areas/Profile/Models/User.cs View File

@@ -19,6 +19,12 @@ namespace Teknik.Areas.Profile.Models

public List<Group> Groups { get; set; }

public string About { get; set; }

public string Website { get; set; }

public string Quote { get; set; }

public User()
{
Username = String.Empty;
@@ -26,6 +32,9 @@ namespace Teknik.Areas.Profile.Models
JoinDate = DateTime.Now;
LastSeen = DateTime.Now;
Groups = new List<Group>();
About = string.Empty;
Website = string.Empty;
Quote = string.Empty;
}
}
}

+ 12
- 2
Teknik/Areas/Profile/ProfileAreaRegistration.cs View File

@@ -1,4 +1,5 @@
using System.Web.Mvc;
using System.Web.Optimization;

namespace Teknik.Areas.Profile
{
@@ -45,7 +46,7 @@ namespace Teknik.Areas.Profile
context.MapSubdomainRoute(
"Profile.Action", // Route name
"dev",
"Profile/{controller}/{action}", // URL with parameters
"Profile/Action/{action}", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
@@ -80,10 +81,19 @@ namespace Teknik.Areas.Profile
context.MapSubdomainRoute(
"Profile.Action", // Route name
"profile",
"{controller}/{action}", // URL with parameters
"Action/{action}", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);

// Register Script Bundle
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/profile").Include(
"~/Scripts/bootbox/bootbox.min.js",
"~/Scripts/PageDown/Markdown.Converter.js",
"~/Scripts/PageDown/Markdown.Sanitizer.js",
"~/Scripts/bootstrap/markdown/bootstrap-markdown.js",
"~/Scripts/jquery.blockUI.js",
"~/Areas/Profile/Scripts/Profile.js"));
}
}
}

+ 61
- 0
Teknik/Areas/Profile/Scripts/Profile.js View File

@@ -0,0 +1,61 @@
$(document).ready(function () {
$('#delete_account').click(function () {
bootbox.confirm("Are you sure you want to delete your account?", function (result) {
if (result) {
$.ajax({
type: "POST",
url: deleteUserURL,
success: function (html) {
if (html.result) {
window.location.reload();
}
else {
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Unable to delete your account. Please contact an Administrator.</div>');
}
}
});
}
});
});

$("#update_submit").click(function () {
// Start Updating Animation
$.blockUI({ message: '<div class="text-center"><h3>Updating...</h3></div>' });

current_password = $("#update_password_current").val();
password = $("#update_password").val();
password_confirm = $("#update_password_confirm").val();
website = $("#update_website").val();
quote = $("#update_quote").val();
about = $("#update_about").val();
blog_title = $("#update_blog_title").val();
blog_desc = $("#update_blog_description").val();
$.ajax({
type: "POST",
url: editUserURL,
data: {
curPass: current_password,
newPass: password,
newPassConfirm: password_confirm,
website: website,
quote: quote,
about: about,
blogTitle: blog_title,
blogDesc: blog_desc
},
success: function (html) {
if (html.result) {
$.unblockUI();
window.location.reload();
}
else {
$.unblockUI();
$("#top_msg").css('display', 'inline', 'important');
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' + html.error + '</div>');
}
}
});
return false;
});
});

+ 0
- 16
Teknik/Areas/Profile/ViewModels/LoginViewModel.cs View File

@@ -27,21 +27,5 @@ namespace Teknik.Areas.Profile.ViewModels
public bool RememberMe { get; set; }

public string ReturnUrl { get; set; }

public bool IsValid()
{
return IsValid(Username, Password);
}

public bool IsValid(string username, string password)
{
var myUser = db.Users.Where(b => b.Username == username).FirstOrDefault();

if (myUser != null && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
{
return (myUser.HashedPassword == SHA384.Hash(username, password));
}
return false;
}
}
}

+ 19
- 0
Teknik/Areas/Profile/ViewModels/ProfileViewModel.cs View File

@@ -8,5 +8,24 @@ namespace Teknik.Areas.Profile.ViewModels
{
public class ProfileViewModel : ViewModelBase
{
public int UserID { get; set; }

public string Username { get; set; }

public string Email { get; set; }

public DateTime JoinDate { get; set; }

public DateTime LastSeen { get; set; }

public string About { get; set; }

public string Website { get; set; }

public string Quote { get; set; }

public string BlogTitle { get; set; }

public string BlogDescription { get; set; }
}
}

+ 0
- 2
Teknik/Areas/Profile/ViewModels/RegisterViewModel.cs View File

@@ -9,8 +9,6 @@ namespace Teknik.Areas.Profile.ViewModels
{
public class RegisterViewModel : ViewModelBase
{
private TeknikEntities db = new TeknikEntities();

[Required]
[Display(Name = "Username")]
public string Username { get; set; }

+ 212
- 1
Teknik/Areas/Profile/Views/Profile/Index.cshtml View File

@@ -1 +1,212 @@
@model Teknik.Areas.Profile.ViewModels.ProfileViewModel
@model Teknik.Areas.Profile.ViewModels.ProfileViewModel

<script>
var editUserURL = '@Url.SubRouteUrl("profile", "Profile.Action", new { action = "Edit" })';
var deleteUserURL = '@Url.SubRouteUrl("profile", "Profile.Action", new { action = "Delete" })';
</script>

@Scripts.Render("~/bundles/profile")

@{
bool OwnProfile = (Model.Username == User.Identity.Name);
}

<div class="container">
@if (Model != null)
{
<div class="row">
<div class="col-sm-3@((string.IsNullOrEmpty(Model.About) && !OwnProfile) ? " col-sm-offset-4" : string.Empty)"><h1>@Model.Username></h1></div>
</div>
<div class="row">
<div class="col-sm-3@((string.IsNullOrEmpty(Model.About) && !OwnProfile) ? " col-sm-offset-4" : string.Empty)"><!--left col-->
<ul class="list-group">
<li class="list-group-item text-muted">Profile</li>
<li class="list-group-item text-right"><span class="pull-left"><strong>Joined</strong></span> @Model.JoinDate.ToString("MMMM dd, yyyy")</li>
@if (OwnProfile && User.Identity.IsAuthenticated)
{
<li class="list-group-item text-right"><span class="pull-left"><strong>Last Seen</strong></span> @Model.LastSeen.ToString("MMMM dd, yyyy")</li>
}
<li class="list-group-item text-right"><span class="pull-left"><strong>Email</strong></span> <a href="mailto:@Model.Email">@Model.Email</a></li>
@if (!string.IsNullOrEmpty(Model.BlogTitle))
{
<li class="list-group-item text-right"><span class="pull-left"><strong>Blog</strong></span> <a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = Model.Username })" id="blog_title">@Model.BlogTitle</a></li>
}
<li class="list-group-item text-right"><span class="pull-left"><strong>Git</strong></span> <a href="@Url.SubRouteUrl("git", "Git.Index", new { username = Model.Username })">Public Repos</a></li>
@if (OwnProfile)
{
<li class="list-group-item text-center"><button type="button" class="btn btn-danger" id="delete_account">Delete Account</button></li>
}
</ul>
@if (!string.IsNullOrEmpty(Model.Website))
{
<div class="panel panel-default">
<div class="panel-heading">Website <i class="fa fa-link fa-1x"></i></div>
<div class="panel-body"><a href="@Model.Website" id="website">@Model.Website</a></div>
</div>
}
@if (!string.IsNullOrEmpty(Model.Quote))
{
<div class="panel panel-default">
<div class="panel-heading">Quote <i class="fa fa-quote-right fa-1x"></i></div>
<div class="panel-body" id="quote">@Model.Quote</div>
</div>
}
</div><!--/col-3-->
<div class="col-sm-9">
@if (!string.IsNullOrEmpty(Model.About) && OwnProfile)
{
<ul class="nav nav-tabs" id="myTab">
@if (!string.IsNullOrEmpty(Model.About))
{
<li @((OwnProfile) ? string.Empty : "class=\"active\"")>
<a href="#about" data-toggle="tab"> About Myself </a>
</li>
}
@if (OwnProfile)
{
<li class="active"><a href="#settings" data-toggle="tab">Settings</a></li>
<li><a href="#privacy" data-toggle="tab">Privacy</a></li>
}
</ul>
}
<div class="tab-content">
@if (!string.IsNullOrEmpty(Model.About))
{
<div class="tab-pane @((!OwnProfile) ? " active" : string.Empty)" id="about">
<script>
$(document).ready(function () {
var converter = new Markdown.getSanitizingConverter();
@if (!string.IsNullOrEmpty(Model.BlogTitle))
{
<text>
// Blog Title Conversion
var old_html = $("#blog_title").text();
var new_html = converter.makeHtml(old_html);
$("#blog_title").html(new_html);
</text>
}

@if (!string.IsNullOrEmpty(Model.Website))
{
<text>
// Website Conversion
var old_html = $("#website").text();
var new_html = converter.makeHtml(old_html);
$("#website").html(new_html);
</text>
}

@if (!string.IsNullOrEmpty(Model.Quote))
{
<text>
// Quote Conversion
var old_html = $("#quote").text();
var new_html = converter.makeHtml(old_html);
$("#quote").html(new_html);
</text>
}

@if (!string.IsNullOrEmpty(Model.About))
{
<text>
// About Conversion
var old_about = $("#markdown_body").text();
var new_about = converter.makeHtml(old_about);
$("#markdown_body").html(new_about);
</text>
}
});
</script>
<div class="col-sm-12" id="markdown_body">@Model.About</div>
</div><!--/tab-pane-->
}
@if (OwnProfile)
{
<div class="tab-pane active" id="settings">
<form class="form" action="##" method="post" id="updateForm">
<input name="update_userid" id="update_userid" type="hidden" value="@Model.UserID" />
<!-- Profile Settings -->
<div class="row">
<div class="col-sm-12 text-center">
<h3>Profile Settings</h3>
</div>
</div>
<hr>
<div class="row">
<div class="form-group col-sm-4">
<label for="update_password_current"><h4>Current Password</h4></label>
<input class="form-control" name="update_password_current" id="update_password_current" placeholder="current password" title="enter your current password." type="password" />
</div>
<div class="form-group col-sm-4">
<label for="update_password"><h4>New Password</h4></label>
<input class="form-control" name="update_password" id="update_password" placeholder="new password" title="enter your password." type="password" />
</div>
<div class="form-group col-sm-4">
<label for="update_password_confirm"><h4>Verify New Password</h4></label>
<input class="form-control" name="update_password_confirm" id="update_password_confirm" placeholder="new password confirmed" title="enter your password again." type="password" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-6">
<label for="update_website"><h4>Website</h4></label>
<input class="form-control" id="update_website" name="update_website" placeholder="http://www.noneofyourbusiness.com/" title="enter your website" type="text" value="@Model.Website" />
</div>
<div class="form-group col-sm-6">
<label for="update_quote"><h4>Quote</h4></label>
<input class="form-control" id="update_quote" name="update_quote" placeholder="I have a dream!" title="enter a memorable quote" type="text" value="@Model.Quote" maxlength="140" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="update_about"><h4>About Yourself</h4></label>
<textarea class="form-control" name="update_about" id="update_about" placeholder="I'm awesome" title="enter any information you want to share with the world." data-provide="markdown" rows="10">@Model.About</textarea>
</div>
</div>
<!-- Blog Settings -->
<div class="row">
<div class="col-sm-12 text-center">
<h3>Blog Settings</h3>
</div>
</div>
<hr>
<div class="row">
<div class="form-group col-sm-6">
<label for="update_blog_title"><h4>Title</h4></label>
<input class="form-control" id="update_blog_title" name="update_blog_title" placeholder="click bait" title="enter your blog's title" type="text" value="@Model.BlogTitle" />
</div>
<div class="form-group col-sm-6">
<label for="update_blog_description"><h4>Description</h4></label>
<input class="form-control" id="update_blog_description" name="update_blog_description" placeholder="This blog is not worth reading." title="enter your blog's description" type="text" value="@Model.BlogDescription" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<br />
<button class="btn btn-lg btn-success" id="update_submit" type="submit"><i class="glyphicon glyphicon-ok-sign"></i> Save</button>
<button class="btn btn-lg" type="reset"><i class="glyphicon glyphicon-repeat"></i> Reset</button>
</div>
</div>
</form>
</div><!--/tab-pane-->
<div class="tab-pane" id="privacy">
<div class="row">
<div class="col-sm-12 text-center">
<iframe style="border: 0; width: 100%;" src="https://stats.teknik.io/index.php?module=CoreAdminHome&action=optOut&language=en"></iframe>
</div>
</div>
</div>
}
</div><!--/tab-content-->

</div><!--/col-9-->
</div><!--/row-->
}
else
{
<div class="row">
<div class="col-sm-12 text-center">
<h2>Sorry, but I couldn't find that user.</h2>
</div>
</div>
}
</div>

BIN
Teknik/Scripts/_references.js View File


Teknik/Scripts/bootstrap/select/bootstrap-select.js → Teknik/Scripts/bootstrap-select.js View File


+ 0
- 6
Teknik/Scripts/bootstrap/bootstrap.min.js
File diff suppressed because it is too large
View File


+ 0
- 1
Teknik/Scripts/bootstrap/image-gallery/bootstrap-image-gallery.min.js View File

@@ -1 +0,0 @@
!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery","./blueimp-gallery"],a):a(window.jQuery,window.blueimp.Gallery)}(function(a,b){"use strict";a.extend(b.prototype.options,{useBootstrapModal:!0});var c=b.prototype.close,d=b.prototype.imageFactory,e=b.prototype.videoFactory,f=b.prototype.textFactory;a.extend(b.prototype,{modalFactory:function(a,b,c,d){if(!this.options.useBootstrapModal||c)return d.call(this,a,b,c);var e=this,f=this.container.children(".modal"),g=f.clone().show().on("click",function(a){(a.target===g[0]||a.target===g.children()[0])&&(a.preventDefault(),a.stopPropagation(),e.close())}),h=d.call(this,a,function(a){b({type:a.type,target:g[0]}),g.addClass("in")},c);return g.find(".modal-title").text(h.title||String.fromCharCode(160)),g.find(".modal-body").append(h),g[0]},imageFactory:function(a,b,c){return this.modalFactory(a,b,c,d)},videoFactory:function(a,b,c){return this.modalFactory(a,b,c,e)},textFactory:function(a,b,c){return this.modalFactory(a,b,c,f)},close:function(){this.container.find(".modal").removeClass("in"),c.call(this)}})});

+ 0
- 1302
Teknik/Scripts/bootstrap/markdown/bootstrap-markdown.js
File diff suppressed because it is too large
View File


+ 0
- 379
Teknik/Scripts/bootstrap/modal/bootstrap-modal.js View File

@@ -1,379 +0,0 @@
/* ===========================================================
* bootstrap-modal.js v2.2.0
* ===========================================================
* Copyright 2012 Jordan Schroter
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */


!function ($) {

"use strict"; // jshint ;_;

/* MODAL CLASS DEFINITION
* ====================== */

var Modal = function (element, options) {
this.init(element, options);
};

Modal.prototype = {

constructor: Modal,

init: function (element, options) {
var that = this;

this.options = options;

this.$element = $(element)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this));

this.options.remote && this.$element.find('.modal-body').load(this.options.remote, function () {
var e = $.Event('loaded');
that.$element.trigger(e);
});

var manager = typeof this.options.manager === 'function' ?
this.options.manager.call(this) : this.options.manager;

manager = manager.appendModal ?
manager : $(manager).modalmanager().data('modalmanager');

manager.appendModal(this);
},

toggle: function () {
return this[!this.isShown ? 'show' : 'hide']();
},

show: function () {
var e = $.Event('show');

if (this.isShown) return;

this.$element.trigger(e);

if (e.isDefaultPrevented()) return;

this.escape();

this.tab();

this.options.loading && this.loading();
},

hide: function (e) {
e && e.preventDefault();

e = $.Event('hide');

this.$element.trigger(e);

if (!this.isShown || e.isDefaultPrevented()) return (this.isShown = false);

this.isShown = false;

this.escape();

this.tab();

this.isLoading && this.loading();

$(document).off('focusin.modal');

this.$element
.removeClass('in')
.removeClass('animated')
.removeClass(this.options.attentionAnimation)
.removeClass('modal-overflow')
.attr('aria-hidden', true);

$.support.transition && this.$element.hasClass('fade') ?
this.hideWithTransition() :
this.hideModal();
},

layout: function () {
var prop = this.options.height ? 'height' : 'max-height',
value = this.options.height || this.options.maxHeight;

if (this.options.width){
this.$element.css('width', this.options.width);

var that = this;
this.$element.css('margin-left', function () {
if (/%/ig.test(that.options.width)){
return -(parseInt(that.options.width) / 2) + '%';
} else {
return -($(this).width() / 2) + 'px';
}
});
} else {
this.$element.css('width', '');
this.$element.css('margin-left', '');
}

this.$element.find('.modal-body')
.css('overflow', '')
.css(prop, '');

if (value){
this.$element.find('.modal-body')
.css('overflow', 'auto')
.css(prop, value);
}

var modalOverflow = $(window).height() - 10 < this.$element.height();
if (modalOverflow || this.options.modalOverflow) {
this.$element
.css('margin-top', 0)
.addClass('modal-overflow');
} else {
this.$element
.css('margin-top', 0 - this.$element.height() / 2)
.removeClass('modal-overflow');
}
},

tab: function () {
var that = this;

if (this.isShown && this.options.consumeTab) {
this.$element.on('keydown.tabindex.modal', '[data-tabindex]', function (e) {
if (e.keyCode && e.keyCode == 9){
var $next = $(this),
$rollover = $(this);

that.$element.find('[data-tabindex]:enabled:not([readonly])').each(function (e) {
if (!e.shiftKey){
$next = $next.data('tabindex') < $(this).data('tabindex') ?
$next = $(this) :
$rollover = $(this);
} else {
$next = $next.data('tabindex') > $(this).data('tabindex') ?
$next = $(this) :
$rollover = $(this);
}
});

$next[0] !== $(this)[0] ?
$next.focus() : $rollover.focus();

e.preventDefault();
}
});
} else if (!this.isShown) {
this.$element.off('keydown.tabindex.modal');
}
},

escape: function () {
var that = this;
if (this.isShown && this.options.keyboard) {
if (!this.$element.attr('tabindex')) this.$element.attr('tabindex', -1);

this.$element.on('keyup.dismiss.modal', function (e) {
e.which == 27 && that.hide();
});
} else if (!this.isShown) {
this.$element.off('keyup.dismiss.modal')
}
},

hideWithTransition: function () {
var that = this
, timeout = setTimeout(function () {
that.$element.off($.support.transition.end);
that.hideModal();
}, 500);

this.$element.one($.support.transition.end, function () {
clearTimeout(timeout);
that.hideModal();
});
},

hideModal: function () {
var prop = this.options.height ? 'height' : 'max-height';
var value = this.options.height || this.options.maxHeight;

if (value){
this.$element.find('.modal-body')
.css('overflow', '')
.css(prop, '');
}

this.$element
.hide()
.trigger('hidden');
},

removeLoading: function () {
this.$loading.remove();
this.$loading = null;
this.isLoading = false;
},

loading: function (callback) {
callback = callback || function () {};

var animate = this.$element.hasClass('fade') ? 'fade' : '';

if (!this.isLoading) {
var doAnimate = $.support.transition && animate;

this.$loading = $('<div class="loading-mask ' + animate + '">')
.append(this.options.spinner)
.appendTo(this.$element);

if (doAnimate) this.$loading[0].offsetWidth; // force reflow

this.$loading.addClass('in');

this.isLoading = true;

doAnimate ?
this.$loading.one($.support.transition.end, callback) :
callback();

} else if (this.isLoading && this.$loading) {
this.$loading.removeClass('in');

var that = this;
$.support.transition && this.$element.hasClass('fade')?
this.$loading.one($.support.transition.end, function () { that.removeLoading() }) :
that.removeLoading();

} else if (callback) {
callback(this.isLoading);
}
},

focus: function () {
var $focusElem = this.$element.find(this.options.focusOn);

$focusElem = $focusElem.length ? $focusElem : this.$element;

$focusElem.focus();
},

attention: function (){
// NOTE: transitionEnd with keyframes causes odd behaviour

if (this.options.attentionAnimation){
this.$element
.removeClass('animated')
.removeClass(this.options.attentionAnimation);

var that = this;

setTimeout(function () {
that.$element
.addClass('animated')
.addClass(that.options.attentionAnimation);
}, 0);
}


this.focus();
},


destroy: function () {
var e = $.Event('destroy');
this.$element.trigger(e);
if (e.isDefaultPrevented()) return;

this.teardown();
},

teardown: function () {
if (!this.$parent.length){
this.$element.remove();
this.$element = null;
return;
}

if (this.$parent !== this.$element.parent()){
this.$element.appendTo(this.$parent);
}

this.$element.off('.modal');
this.$element.removeData('modal');
this.$element
.removeClass('in')
.attr('aria-hidden', true);
}
};


/* MODAL PLUGIN DEFINITION
* ======================= */

$.fn.modal = function (option, args) {
return this.each(function () {
var $this = $(this),
data = $this.data('modal'),
options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option);

if (!data) $this.data('modal', (data = new Modal(this, options)));
if (typeof option == 'string') data[option].apply(data, [].concat(args));
else if (options.show) data.show()
})
};

$.fn.modal.defaults = {
keyboard: true,
backdrop: true,
loading: false,
show: true,
width: null,
height: null,
maxHeight: null,
modalOverflow: false,
consumeTab: true,
focusOn: null,
replace: false,
resize: false,
attentionAnimation: 'shake',
manager: 'body',
spinner: '<div class="loading-spinner" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>',
backdropTemplate: '<div class="modal-backdrop" />'
};

$.fn.modal.Constructor = Modal;


/* MODAL DATA-API
* ============== */

$(function () {
$(document).off('click.modal').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this),
href = $this.attr('href'),
$target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))), //strip for ie7
option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());

e.preventDefault();
$target
.modal(option)
.one('hide', function () {
$this.focus();
})
});
});

}(window.jQuery);

+ 0
- 422
Teknik/Scripts/bootstrap/modal/bootstrap-modalmanager.js View File

@@ -1,422 +0,0 @@
/* ===========================================================
* bootstrap-modalmanager.js v2.2.0
* ===========================================================
* Copyright 2012 Jordan Schroter.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */

!function ($) {

"use strict"; // jshint ;_;

/* MODAL MANAGER CLASS DEFINITION
* ====================== */

var ModalManager = function (element, options) {
this.init(element, options);
};

ModalManager.prototype = {

constructor: ModalManager,

init: function (element, options) {
this.$element = $(element);
this.options = $.extend({}, $.fn.modalmanager.defaults, this.$element.data(), typeof options == 'object' && options);
this.stack = [];
this.backdropCount = 0;

if (this.options.resize) {
var resizeTimeout,
that = this;

$(window).on('resize.modal', function(){
resizeTimeout && clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function(){
for (var i = 0; i < that.stack.length; i++){
that.stack[i].isShown && that.stack[i].layout();
}
}, 10);
});
}
},

createModal: function (element, options) {
$(element).modal($.extend({ manager: this }, options));
},

appendModal: function (modal) {
this.stack.push(modal);

var that = this;

modal.$element.on('show.modalmanager', targetIsSelf(function (e) {

var showModal = function(){
modal.isShown = true;

var transition = $.support.transition && modal.$element.hasClass('fade');

that.$element
.toggleClass('modal-open', that.hasOpenModal())
.toggleClass('page-overflow', $(window).height() < that.$element.height());

modal.$parent = modal.$element.parent();

modal.$container = that.createContainer(modal);

modal.$element.appendTo(modal.$container);

that.backdrop(modal, function () {
modal.$element.show();

if (transition) {
//modal.$element[0].style.display = 'run-in';
modal.$element[0].offsetWidth;
//modal.$element.one($.support.transition.end, function () { modal.$element[0].style.display = 'block' });
}
modal.layout();

modal.$element
.addClass('in')
.attr('aria-hidden', false);

var complete = function () {
that.setFocus();
modal.$element.trigger('shown');
};

transition ?
modal.$element.one($.support.transition.end, complete) :
complete();
});
};

modal.options.replace ?
that.replace(showModal) :
showModal();
}));

modal.$element.on('hidden.modalmanager', targetIsSelf(function (e) {

that.backdrop(modal);
if (modal.$backdrop){
var transition = $.support.transition && modal.$element.hasClass('fade');

// trigger a relayout due to firebox's buggy transition end event
if (transition) { modal.$element[0].offsetWidth; }

$.support.transition && modal.$element.hasClass('fade') ?
modal.$backdrop.one($.support.transition.end, function () { that.destroyModal(modal) }) :
that.destroyModal(modal);
} else {
that.destroyModal(modal);
}

}));

modal.$element.on('destroy.modalmanager', targetIsSelf(function (e) {
that.removeModal(modal);
}));

},

destroyModal: function (modal) {
modal.destroy();

var hasOpenModal = this.hasOpenModal();

this.$element.toggleClass('modal-open', hasOpenModal);

if (!hasOpenModal){
this.$element.removeClass('page-overflow');
}

this.removeContainer(modal);

this.setFocus();
},

getOpenModals: function () {
var openModals = [];
for (var i = 0; i < this.stack.length; i++){
if (this.stack[i].isShown) openModals.push(this.stack[i]);
}

return openModals;
},

hasOpenModal: function () {
return this.getOpenModals().length > 0;
},

setFocus: function () {
var topModal;

for (var i = 0; i < this.stack.length; i++){
if (this.stack[i].isShown) topModal = this.stack[i];
}

if (!topModal) return;

topModal.focus();

},

removeModal: function (modal) {
modal.$element.off('.modalmanager');
if (modal.$backdrop) this.removeBackdrop(modal);
this.stack.splice(this.getIndexOfModal(modal), 1);
},

getModalAt: function (index) {
return this.stack[index];
},

getIndexOfModal: function (modal) {
for (var i = 0; i < this.stack.length; i++){
if (modal === this.stack[i]) return i;
}
},

replace: function (callback) {
var topModal;

for (var i = 0; i < this.stack.length; i++){
if (this.stack[i].isShown) topModal = this.stack[i];
}

if (topModal) {
this.$backdropHandle = topModal.$backdrop;
topModal.$backdrop = null;

callback && topModal.$element.one('hidden',
targetIsSelf( $.proxy(callback, this) ));

topModal.hide();
} else if (callback) {
callback();
}
},

removeBackdrop: function (modal) {
modal.$backdrop.remove();
modal.$backdrop = null;
},

createBackdrop: function (animate, tmpl) {
var $backdrop;

if (!this.$backdropHandle) {
$backdrop = $(tmpl)
.addClass(animate)
.appendTo(this.$element);
} else {
$backdrop = this.$backdropHandle;
$backdrop.off('.modalmanager');
this.$backdropHandle = null;
this.isLoading && this.removeSpinner();
}

return $backdrop;
},

removeContainer: function (modal) {
modal.$container.remove();
modal.$container = null;
},

createContainer: function (modal) {
var $container;

$container = $('<div class="modal-scrollable">')
.css('z-index', getzIndex('modal', this.getOpenModals().length))
.appendTo(this.$element);

if (modal && modal.options.backdrop != 'static') {
$container.on('click.modal', targetIsSelf(function (e) {
modal.hide();
}));
} else if (modal) {
$container.on('click.modal', targetIsSelf(function (e) {
modal.attention();
}));
}

return $container;

},

backdrop: function (modal, callback) {
var animate = modal.$element.hasClass('fade') ? 'fade' : '',
showBackdrop = modal.options.backdrop &&
this.backdropCount < this.options.backdropLimit;

if (modal.isShown && showBackdrop) {
var doAnimate = $.support.transition && animate && !this.$backdropHandle;

modal.$backdrop = this.createBackdrop(animate, modal.options.backdropTemplate);

modal.$backdrop.css('z-index', getzIndex( 'backdrop', this.getOpenModals().length ));

if (doAnimate) modal.$backdrop[0].offsetWidth; // force reflow

modal.$backdrop.addClass('in');

this.backdropCount += 1;

doAnimate ?
modal.$backdrop.one($.support.transition.end, callback) :
callback();

} else if (!modal.isShown && modal.$backdrop) {
modal.$backdrop.removeClass('in');

this.backdropCount -= 1;

var that = this;

$.support.transition && modal.$element.hasClass('fade')?
modal.$backdrop.one($.support.transition.end, function () { that.removeBackdrop(modal) }) :
that.removeBackdrop(modal);

} else if (callback) {
callback();
}
},

removeSpinner: function(){
this.$spinner && this.$spinner.remove();
this.$spinner = null;
this.isLoading = false;
},

removeLoading: function () {
this.$backdropHandle && this.$backdropHandle.remove();
this.$backdropHandle = null;
this.removeSpinner();
},

loading: function (callback) {
callback = callback || function () { };

this.$element
.toggleClass('modal-open', !this.isLoading || this.hasOpenModal())
.toggleClass('page-overflow', $(window).height() < this.$element.height());

if (!this.isLoading) {

this.$backdropHandle = this.createBackdrop('fade', this.options.backdropTemplate);

this.$backdropHandle[0].offsetWidth; // force reflow

var openModals = this.getOpenModals();

this.$backdropHandle
.css('z-index', getzIndex('backdrop', openModals.length + 1))
.addClass('in');

var $spinner = $(this.options.spinner)
.css('z-index', getzIndex('modal', openModals.length + 1))
.appendTo(this.$element)
.addClass('in');

this.$spinner = $(this.createContainer())
.append($spinner)
.on('click.modalmanager', $.proxy(this.loading, this));

this.isLoading = true;

$.support.transition ?
this.$backdropHandle.one($.support.transition.end, callback) :
callback();

} else if (this.isLoading && this.$backdropHandle) {
this.$backdropHandle.removeClass('in');

var that = this;
$.support.transition ?
this.$backdropHandle.one($.support.transition.end, function () { that.removeLoading() }) :
that.removeLoading();

} else if (callback) {
callback(this.isLoading);
}
}
};

/* PRIVATE METHODS
* ======================= */

// computes and caches the zindexes
var getzIndex = (function () {
var zIndexFactor,
baseIndex = {};

return function (type, pos) {

if (typeof zIndexFactor === 'undefined'){
var $baseModal = $('<div class="modal hide" />').appendTo('body'),
$baseBackdrop = $('<div class="modal-backdrop hide" />').appendTo('body');

baseIndex['modal'] = +$baseModal.css('z-index');
baseIndex['backdrop'] = +$baseBackdrop.css('z-index');
zIndexFactor = baseIndex['modal'] - baseIndex['backdrop'];

$baseModal.remove();
$baseBackdrop.remove();
$baseBackdrop = $baseModal = null;
}

return baseIndex[type] + (zIndexFactor * pos);

}
}());

// make sure the event target is the modal itself in order to prevent
// other components such as tabsfrom triggering the modal manager.
// if Boostsrap namespaced events, this would not be needed.
function targetIsSelf(callback){
return function (e) {
if (this === e.target){
return callback.apply(this, arguments);
}
}
}


/* MODAL MANAGER PLUGIN DEFINITION
* ======================= */

$.fn.modalmanager = function (option, args) {
return this.each(function () {
var $this = $(this),
data = $this.data('modalmanager');

if (!data) $this.data('modalmanager', (data = new ModalManager(this, option)));
if (typeof option === 'string') data[option].apply(data, [].concat(args))
})
};

$.fn.modalmanager.defaults = {
backdropLimit: 999,
resize: true,
spinner: '<div class="loading-spinner fade" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>',
backdropTemplate: '<div class="modal-backdrop" />'
};

$.fn.modalmanager.Constructor = ModalManager

}(jQuery);

+ 0
- 622
Teknik/Scripts/bootstrap/tags/bootstrap-tags.js View File

@@ -1,622 +0,0 @@
/*!
* bootstrap-tags 1.1.5
* https://github.com/maxwells/bootstrap-tags
* Copyright 2013 Max Lahey; Licensed MIT
*/

(function($) {
(function() {
window.Tags || (window.Tags = {});
jQuery(function() {
$.tags = function(element, options) {
var key, tag, tagData, value, _i, _len, _ref, _this = this;
if (options == null) {
options = {};
}
for (key in options) {
value = options[key];
this[key] = value;
}
this.bootstrapVersion || (this.bootstrapVersion = "3");
this.readOnly || (this.readOnly = false);
this.suggestOnClick || (this.suggestOnClick = false);
this.suggestions || (this.suggestions = []);
this.restrictTo = options.restrictTo != null ? options.restrictTo.concat(this.suggestions) : false;
this.exclude || (this.exclude = false);
this.displayPopovers = options.popovers != null ? true : options.popoverData != null;
this.popoverTrigger || (this.popoverTrigger = "hover");
this.tagClass || (this.tagClass = "btn-info");
this.tagSize || (this.tagSize = "md");
this.promptText || (this.promptText = "Enter tags...");
this.caseInsensitive || (this.caseInsensitive = false);
this.readOnlyEmptyMessage || (this.readOnlyEmptyMessage = "No tags to display...");
this.maxNumTags || (this.maxNumTags = -1);
this.beforeAddingTag || (this.beforeAddingTag = function(tag) {});
this.afterAddingTag || (this.afterAddingTag = function(tag) {});
this.beforeDeletingTag || (this.beforeDeletingTag = function(tag) {});
this.afterDeletingTag || (this.afterDeletingTag = function(tag) {});
this.definePopover || (this.definePopover = function(tag) {
return 'associated content for "' + tag + '"';
});
this.excludes || (this.excludes = function() {
return false;
});
this.tagRemoved || (this.tagRemoved = function(tag) {});
this.pressedReturn || (this.pressedReturn = function(e) {});
this.pressedDelete || (this.pressedDelete = function(e) {});
this.pressedDown || (this.pressedDown = function(e) {});
this.pressedUp || (this.pressedUp = function(e) {});
this.$element = $(element);
if (options.tagData != null) {
this.tagsArray = options.tagData;
} else {
tagData = $(".tag-data", this.$element).html();
this.tagsArray = tagData != null ? tagData.split(",") : [];
}
if (options.popoverData) {
this.popoverArray = options.popoverData;
} else {
this.popoverArray = [];
_ref = this.tagsArray;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
tag = _ref[_i];
this.popoverArray.push(null);
}
}
this.getTags = function() {
return _this.tagsArray;
};
this.getTagsContent = function() {
return _this.popoverArray;
};
this.getTagsWithContent = function() {
var combined, i, _j, _ref1;
combined = [];
for (i = _j = 0, _ref1 = _this.tagsArray.length - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
combined.push({
tag: _this.tagsArray[i],
content: _this.popoverArray[i]
});
}
return combined;
};
this.getTag = function(tag) {
var index;
index = _this.tagsArray.indexOf(tag);
if (index > -1) {
return _this.tagsArray[index];
} else {
return null;
}
};
this.getTagWithContent = function(tag) {
var index;
index = _this.tagsArray.indexOf(tag);
return {
tag: _this.tagsArray[index],
content: _this.popoverArray[index]
};
};
this.hasTag = function(tag) {
return _this.tagsArray.indexOf(tag) > -1;
};
this.removeTagClicked = function(e) {
if (e.currentTarget.tagName === "A") {
_this.removeTag($("span", e.currentTarget.parentElement).html());
$(e.currentTarget.parentNode).remove();
}
return _this;
};
this.removeLastTag = function() {
if (_this.tagsArray.length > 0) {
_this.removeTag(_this.tagsArray[_this.tagsArray.length - 1]);
if (_this.canAddByMaxNum()) {
_this.enableInput();
}
}
return _this;
};
this.removeTag = function(tag) {
if (_this.tagsArray.indexOf(tag) > -1) {
if (_this.beforeDeletingTag(tag) === false) {
return;
}
_this.popoverArray.splice(_this.tagsArray.indexOf(tag), 1);
_this.tagsArray.splice(_this.tagsArray.indexOf(tag), 1);
_this.renderTags();
_this.afterDeletingTag(tag);
if (_this.canAddByMaxNum()) {
_this.enableInput();
}
}
return _this;
};
this.canAddByRestriction = function(tag) {
return this.restrictTo === false || this.restrictTo.indexOf(tag) !== -1;
};
this.canAddByExclusion = function(tag) {
return (this.exclude === false || this.exclude.indexOf(tag) === -1) && !this.excludes(tag);
};
this.canAddByMaxNum = function() {
return this.maxNumTags === -1 || this.tagsArray.length < this.maxNumTags;
};
this.addTag = function(tag) {
var associatedContent;
if (_this.canAddByRestriction(tag) && !_this.hasTag(tag) && tag.length > 0 && _this.canAddByExclusion(tag) && _this.canAddByMaxNum()) {
if (_this.beforeAddingTag(tag) === false) {
return;
}
associatedContent = _this.definePopover(tag);
_this.popoverArray.push(associatedContent || null);
_this.tagsArray.push(tag);
_this.afterAddingTag(tag);
_this.renderTags();
if (!_this.canAddByMaxNum()) {
_this.disableInput();
}
}
return _this;
};
this.addTagWithContent = function(tag, content) {
if (_this.canAddByRestriction(tag) && !_this.hasTag(tag) && tag.length > 0) {
if (_this.beforeAddingTag(tag) === false) {
return;
}
_this.tagsArray.push(tag);
_this.popoverArray.push(content);
_this.afterAddingTag(tag);
_this.renderTags();
}
return _this;
};
this.renameTag = function(name, newName) {
_this.tagsArray[_this.tagsArray.indexOf(name)] = newName;
_this.renderTags();
return _this;
};
this.setPopover = function(tag, popoverContent) {
_this.popoverArray[_this.tagsArray.indexOf(tag)] = popoverContent;
_this.renderTags();
return _this;
};
this.clickHandler = function(e) {
return _this.makeSuggestions(e, true);
};
this.keyDownHandler = function(e) {
var k, numSuggestions;
k = e.keyCode != null ? e.keyCode : e.which;
switch (k) {
case 13:
e.preventDefault();
_this.pressedReturn(e);
tag = e.target.value;
if (_this.suggestedIndex !== -1) {
tag = _this.suggestionList[_this.suggestedIndex];
}
_this.addTag(tag);
e.target.value = "";
_this.renderTags();
return _this.hideSuggestions();

case 46:
case 8:
_this.pressedDelete(e);
if (e.target.value === "") {
_this.removeLastTag();
}
if (e.target.value.length === 1) {
return _this.hideSuggestions();
}
break;

case 40:
_this.pressedDown(e);
if (_this.input.val() === "" && (_this.suggestedIndex === -1 || _this.suggestedIndex == null)) {
_this.makeSuggestions(e, true);
}
numSuggestions = _this.suggestionList.length;
_this.suggestedIndex = _this.suggestedIndex < numSuggestions - 1 ? _this.suggestedIndex + 1 : numSuggestions - 1;
_this.selectSuggested(_this.suggestedIndex);
if (_this.suggestedIndex >= 0) {
return _this.scrollSuggested(_this.suggestedIndex);
}
break;

case 38:
_this.pressedUp(e);
_this.suggestedIndex = _this.suggestedIndex > 0 ? _this.suggestedIndex - 1 : 0;
_this.selectSuggested(_this.suggestedIndex);
if (_this.suggestedIndex >= 0) {
return _this.scrollSuggested(_this.suggestedIndex);
}
break;

case 9:
case 27:
_this.hideSuggestions();
return _this.suggestedIndex = -1;
}
};
this.keyUpHandler = function(e) {
var k;
k = e.keyCode != null ? e.keyCode : e.which;
if (k !== 40 && k !== 38 && k !== 27) {
return _this.makeSuggestions(e, false);
}
};
this.getSuggestions = function(str, overrideLengthCheck) {
var _this = this;
this.suggestionList = [];
if (this.caseInsensitive) {
str = str.toLowerCase();
}
$.each(this.suggestions, function(i, suggestion) {
var suggestionVal;
suggestionVal = _this.caseInsensitive ? suggestion.substring(0, str.length).toLowerCase() : suggestion.substring(0, str.length);
if (_this.tagsArray.indexOf(suggestion) < 0 && suggestionVal === str && (str.length > 0 || overrideLengthCheck)) {
return _this.suggestionList.push(suggestion);
}
});
return this.suggestionList;
};
this.makeSuggestions = function(e, overrideLengthCheck, val) {
if (val == null) {
val = e.target.value != null ? e.target.value : e.target.textContent;
}
_this.suggestedIndex = -1;
_this.$suggestionList.html("");
$.each(_this.getSuggestions(val, overrideLengthCheck), function(i, suggestion) {
return _this.$suggestionList.append(_this.template("tags_suggestion", {
suggestion: suggestion
}));
});
_this.$(".tags-suggestion").mouseover(_this.selectSuggestedMouseOver);
_this.$(".tags-suggestion").click(_this.suggestedClicked);
if (_this.suggestionList.length > 0) {
return _this.showSuggestions();
} else {
return _this.hideSuggestions();
}
};
this.suggestedClicked = function(e) {
tag = e.target.textContent;
if (_this.suggestedIndex !== -1) {
tag = _this.suggestionList[_this.suggestedIndex];
}
_this.addTag(tag);
_this.input.val("");
_this.makeSuggestions(e, false, "");
_this.input.focus();
return _this.hideSuggestions();
};
this.hideSuggestions = function() {
return _this.$(".tags-suggestion-list").css({
display: "none"
});
};
this.showSuggestions = function() {
return _this.$(".tags-suggestion-list").css({
display: "block"
});
};
this.selectSuggestedMouseOver = function(e) {
$(".tags-suggestion").removeClass("tags-suggestion-highlighted");
$(e.target).addClass("tags-suggestion-highlighted");
$(e.target).mouseout(_this.selectSuggestedMousedOut);
return _this.suggestedIndex = _this.$(".tags-suggestion").index($(e.target));
};
this.selectSuggestedMousedOut = function(e) {
return $(e.target).removeClass("tags-suggestion-highlighted");
};
this.selectSuggested = function(i) {
var tagElement;
$(".tags-suggestion").removeClass("tags-suggestion-highlighted");
tagElement = _this.$(".tags-suggestion").eq(i);
return tagElement.addClass("tags-suggestion-highlighted");
};
this.scrollSuggested = function(i) {
var pos, tagElement, topElement, topPos;
tagElement = _this.$(".tags-suggestion").eq(i);
topElement = _this.$(".tags-suggestion").eq(0);
pos = tagElement.position();
topPos = topElement.position();
if (pos != null) {
return _this.$(".tags-suggestion-list").scrollTop(pos.top - topPos.top);
}
};
this.adjustInputPosition = function() {
var pBottom, pLeft, pTop, pWidth, tagElement, tagPosition;
tagElement = _this.$(".tag").last();
tagPosition = tagElement.position();
pLeft = tagPosition != null ? tagPosition.left + tagElement.outerWidth(true) : 0;
pTop = tagPosition != null ? tagPosition.top : 0;
pWidth = _this.$element.width() - pLeft;
$(".tags-input", _this.$element).css({
paddingLeft: Math.max(pLeft, 0),
paddingTop: Math.max(pTop, 0),
width: pWidth
});
pBottom = tagPosition != null ? tagPosition.top + tagElement.outerHeight(true) : 22;
return _this.$element.css({
paddingBottom: pBottom - _this.$element.height()
});
};
this.renderTags = function() {
var tagList;
tagList = _this.$(".tags");
tagList.html("");
_this.input.attr("placeholder", _this.tagsArray.length === 0 ? _this.promptText : "");
$.each(_this.tagsArray, function(i, tag) {
tag = $(_this.formatTag(i, tag));
$("a", tag).click(_this.removeTagClicked);
$("a", tag).mouseover(_this.toggleCloseColor);
$("a", tag).mouseout(_this.toggleCloseColor);
if (_this.displayPopovers) {
_this.initializePopoverFor(tag, _this.tagsArray[i], _this.popoverArray[i]);
}
return tagList.append(tag);
});
return _this.adjustInputPosition();
};
this.renderReadOnly = function() {
var tagList;
tagList = _this.$(".tags");
tagList.html(_this.tagsArray.length === 0 ? _this.readOnlyEmptyMessage : "");
return $.each(_this.tagsArray, function(i, tag) {
tag = $(_this.formatTag(i, tag, true));
if (_this.displayPopovers) {
_this.initializePopoverFor(tag, _this.tagsArray[i], _this.popoverArray[i]);
}
return tagList.append(tag);
});
};
this.disableInput = function() {
return this.$("input").prop("disabled", true);
};
this.enableInput = function() {
return this.$("input").prop("disabled", false);
};
this.initializePopoverFor = function(tag, title, content) {
options = {
title: title,
content: content,
placement: "bottom"
};
if (_this.popoverTrigger === "hoverShowClickHide") {
$(tag).mouseover(function() {
$(tag).popover("show");
return $(".tag").not(tag).popover("hide");
});
$(document).click(function() {
return $(tag).popover("hide");
});
} else {
options.trigger = _this.popoverTrigger;
}
return $(tag).popover(options);
};
this.toggleCloseColor = function(e) {
var opacity, tagAnchor;
tagAnchor = $(e.currentTarget);
opacity = tagAnchor.css("opacity");
opacity = opacity < .8 ? 1 : .6;
return tagAnchor.css({
opacity: opacity
});
};
this.formatTag = function(i, tag, isReadOnly) {
var escapedTag;
if (isReadOnly == null) {
isReadOnly = false;
}
escapedTag = tag.replace("<", "&lt;").replace(">", "&gt;");
return _this.template("tag", {
tag: escapedTag,
tagClass: _this.tagClass,
isPopover: _this.displayPopovers,
isReadOnly: isReadOnly,
tagSize: _this.tagSize
});
};
this.addDocumentListeners = function() {
return $(document).mouseup(function(e) {
var container;
container = _this.$(".tags-suggestion-list");
if (container.has(e.target).length === 0) {
return _this.hideSuggestions();
}
});
};
this.template = function(name, options) {
return Tags.Templates.Template(this.getBootstrapVersion(), name, options);
};
this.$ = function(selector) {
return $(selector, this.$element);
};
this.getBootstrapVersion = function() {
return Tags.bootstrapVersion || this.bootstrapVersion;
};
this.initializeDom = function() {
return this.$element.append(this.template("tags_container"));
};
this.init = function() {
this.$element.addClass("bootstrap-tags").addClass("bootstrap-" + this.getBootstrapVersion());
this.initializeDom();
if (this.readOnly) {
this.renderReadOnly();
this.removeTag = function() {};
this.removeTagClicked = function() {};
this.removeLastTag = function() {};
this.addTag = function() {};
this.addTagWithContent = function() {};
this.renameTag = function() {};
return this.setPopover = function() {};
} else {
this.input = $(this.template("input", {
tagSize: this.tagSize
}));
if (this.suggestOnClick) {
this.input.click(this.clickHandler);
}
this.input.keydown(this.keyDownHandler);
this.input.keyup(this.keyUpHandler);
this.$element.append(this.input);
this.$suggestionList = $(this.template("suggestion_list"));
this.$element.append(this.$suggestionList);
this.renderTags();
if (!this.canAddByMaxNum()) {
this.disableInput();
}
return this.addDocumentListeners();
}
};
this.init();
return this;
};
return $.fn.tags = function(options) {
var stopOn, tagsObject;
tagsObject = {};
stopOn = typeof options === "number" ? options : -1;
this.each(function(i, el) {
var $el;
$el = $(el);
if ($el.data("tags") == null) {
$el.data("tags", new $.tags(this, options));
}
if (stopOn === i || i === 0) {
return tagsObject = $el.data("tags");
}
});
return tagsObject;
};
});
}).call(this);
(function() {
window.Tags || (window.Tags = {});
Tags.Helpers || (Tags.Helpers = {});
Tags.Helpers.addPadding = function(string, amount, doPadding) {
if (amount == null) {
amount = 1;
}
if (doPadding == null) {
doPadding = true;
}
if (!doPadding) {
return string;
}
if (amount === 0) {
return string;
}
return Tags.Helpers.addPadding("&nbsp" + string + "&nbsp", amount - 1);
};
}).call(this);
(function() {
var _base;
window.Tags || (window.Tags = {});
Tags.Templates || (Tags.Templates = {});
(_base = Tags.Templates)["2"] || (_base["2"] = {});
Tags.Templates["2"].input = function(options) {
var tagSize;
if (options == null) {
options = {};
}
tagSize = function() {
switch (options.tagSize) {
case "sm":
return "small";

case "md":
return "medium";

case "lg":
return "large";
}
}();
return "<input type='text' class='tags-input input-" + tagSize + "' />";
};
}).call(this);
(function() {
var _base;
window.Tags || (window.Tags = {});
Tags.Templates || (Tags.Templates = {});
(_base = Tags.Templates)["2"] || (_base["2"] = {});
Tags.Templates["2"].tag = function(options) {
if (options == null) {
options = {};
}
return "<div class='tag label " + options.tagClass + " " + options.tagSize + "' " + (options.isPopover ? "rel='popover'" : "") + "> <span>" + Tags.Helpers.addPadding(options.tag, 2, options.isReadOnly) + "</span> " + (options.isReadOnly ? "" : "<a><i class='remove icon-remove-sign icon-white' /></a>") + " </div>";
};
}).call(this);
(function() {
var _base;
window.Tags || (window.Tags = {});
Tags.Templates || (Tags.Templates = {});
(_base = Tags.Templates)["3"] || (_base["3"] = {});
Tags.Templates["3"].input = function(options) {
if (options == null) {
options = {};
}
return "<input type='text' class='form-control tags-input input-" + options.tagSize + "' />";
};
}).call(this);
(function() {
var _base;
window.Tags || (window.Tags = {});
Tags.Templates || (Tags.Templates = {});
(_base = Tags.Templates)["3"] || (_base["3"] = {});
Tags.Templates["3"].tag = function(options) {
if (options == null) {
options = {};
}
return "<div class='tag label " + options.tagClass + " " + options.tagSize + "' " + (options.isPopover ? "rel='popover'" : "") + "> <span>" + Tags.Helpers.addPadding(options.tag, 2, options.isReadOnly) + "</span> " + (options.isReadOnly ? "" : "<a><i class='remove glyphicon glyphicon-remove-sign glyphicon-white' /></a>") + " </div>";
};
}).call(this);
(function() {
var _base;
window.Tags || (window.Tags = {});
Tags.Templates || (Tags.Templates = {});
(_base = Tags.Templates).shared || (_base.shared = {});
Tags.Templates.shared.suggestion_list = function(options) {
if (options == null) {
options = {};
}
return '<ul class="tags-suggestion-list dropdown-menu"></ul>';
};
}).call(this);
(function() {
var _base;
window.Tags || (window.Tags = {});
Tags.Templates || (Tags.Templates = {});
(_base = Tags.Templates).shared || (_base.shared = {});
Tags.Templates.shared.tags_container = function(options) {
if (options == null) {
options = {};
}
return '<div class="tags"></div>';
};
}).call(this);
(function() {
var _base;
window.Tags || (window.Tags = {});
Tags.Templates || (Tags.Templates = {});
(_base = Tags.Templates).shared || (_base.shared = {});
Tags.Templates.shared.tags_suggestion = function(options) {
if (options == null) {
options = {};
}
return "<li class='tags-suggestion'>" + options.suggestion + "</li>";
};
}).call(this);
(function() {
window.Tags || (window.Tags = {});
Tags.Templates || (Tags.Templates = {});
Tags.Templates.Template = function(version, templateName, options) {
if (Tags.Templates[version] != null) {
if (Tags.Templates[version][templateName] != null) {
return Tags.Templates[version][templateName](options);
}
}
return Tags.Templates.shared[templateName](options);
};
}).call(this);
})(window.jQuery);

+ 619
- 0
Teknik/Scripts/jquery.blockUI.js View File

@@ -0,0 +1,619 @@
/*!
* jQuery blockUI plugin
* Version 2.66.0-2013.10.09
* Requires jQuery v1.7 or later
*
* Examples at: http://malsup.com/jquery/block/
* Copyright (c) 2007-2013 M. Alsup
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Thanks to Amir-Hossein Sobhi for some excellent contributions!
*/

;(function() {
/*jshint eqeqeq:false curly:false latedef:false */
"use strict";

function setup($) {
$.fn._fadeIn = $.fn.fadeIn;

var noOp = $.noop || function() {};

// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
// confusing userAgent strings on Vista)
var msie = /MSIE/.test(navigator.userAgent);
var ie6 = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent);
var mode = document.documentMode || 0;
var setExpr = $.isFunction( document.createElement('div').style.setExpression );

// global $ methods for blocking/unblocking the entire page
$.blockUI = function(opts) { install(window, opts); };
$.unblockUI = function(opts) { remove(window, opts); };

// convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
$.growlUI = function(title, message, timeout, onClose) {
var $m = $('<div class="growlUI"></div>');
if (title) $m.append('<h1>'+title+'</h1>');
if (message) $m.append('<h2>'+message+'</h2>');
if (timeout === undefined) timeout = 3000;

// Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications
var callBlock = function(opts) {
opts = opts || {};

$.blockUI({
message: $m,
fadeIn : typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700,
fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000,
timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout,
centerY: false,
showOverlay: false,
onUnblock: onClose,
css: $.blockUI.defaults.growlCSS
});
};

callBlock();
var nonmousedOpacity = $m.css('opacity');
$m.mouseover(function() {
callBlock({